package main

import (
	"server/src/logging"
	"server/src/storage"
)

const Version string = "里程统计程序 v1.0 build 200506"

func main() {
	var err error

	initGlobal()

	storage.Init(storage.RootPath())

	// 启动日志
	logging.DisableBootScreenLog()
	logging.LogBoot()

	zLog(nil, Version, " 启动")

	cfg, err := loadConfig("")
	if err != nil {
		zLog(nil, "读配置文件失败:"+err.Error())
		return
	}

	dbo, err := NewDBOperation(cfg)
	if err != nil {
		zLog(nil, "数据库连接失败，程序退出:", err)
		return
	}
	zLog(nil, "数据库连接成功")
	defer dbo.Close()

	ms := NewMileageStatics(cfg, dbo)
	ms.Do()

	zLog(nil, Version, " 退出")
}
